<?php

/**
 * Created by PhpStorm.
 * User: 张彪
 * Date: 2016/5/9 0009
 * Time: 下午 4:08
 */
class Wanfa extends  Base_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->model('article_model');
        $this->load->model('track_model');
        $this->load->model('comment_model');
        $this->load->model('category_model');

    }


    public function getlist()
    {
        $data = $_GET;
        $lines = $this->article_model->track_act_search($data);
        if(!empty($lines))
        {
            $this->success($lines);
        }else{
            $this->error('未找到数据');
        }
    }

    public function detail()
    {
        $id = $_GET['id'];
        if($_GET['type'] == 'TRACK')
        {
            $data = $this->track_model->detail($id);
            $con_data['type'] = 'TRACK';
        }elseif($_GET['type'] == 'ACTIVITY')
        {
            $data = $this->article_model->detail($id);
            $con_data['type'] = 'ACTIVITY';
        }else{
            $this->error('类型错误！');
        }

        $con_data['id'] = $id;
        $con_data['limit'] = 5;
        $con_data['offset'] = 0;
        $coms = $this->comment_model->getActivityOrTrackComments($con_data);

        $this->success(array('data'=>$data,'coms' =>$coms));

    }


    public function gettype()
    {
       $data =  $this->category_model->all_categories(array('parentId'=>3,'type'=>'SUBCAT','select'=>'id,name'));
        $this->success($data);
    }




}